Skip to content

fix(python-uv): reject pruning the project itself; test uv_all_extras - #972

Merged
bnusunny merged 2 commits into
aws:developfrom
bnusunny:fix/python-uv-966-followups
Nov 19, 2026
Merged

bnusunny merged 2 commits into
aws:developfrom
bnusunny:fix/python-uv-966-followups

Conversation

@bnusunny

Copy link
Copy Markdown
Contributor

Issue #, if available: Follow-up to #966

Description of changes

Follow-ups from the review of #966.

  • uv_prune now fails validation when it names the project being built. Before, uv export --prune <project> exported nothing, and the build passed with no dependencies.
  • The project name comes from [project].name in the function's pyproject.toml. Names are compared after PEP 503 normalization, so My_App matches my-app.
  • In a uv workspace, the check covers only the project being built. Pruning another workspace member stays allowed, because a member can be provided at runtime (for example by a layer).
  • If the pyproject.toml has no project name (such as a virtual workspace root) or cannot be read, the check is skipped and uv reports any problem as before.
  • The PEP 503 normalization is now one shared helper, used by this check and by the existing check for prune names missing from uv.lock.
  • test_options_are_passed_to_the_build_action now also covers uv_all_extras: True, as its own case because it cannot be combined with uv_extras.

Description of how you validated changes

  • make lint and make black-check pass.
  • python_uv unit tests: 146 passed.
  • python_uv functional tests: 14 passed.
  • python_uv integration tests with uv 0.13.9: 68 passed. The existing prune test now also checks that pruning the project itself fails with a real uv build.

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@bnusunny
bnusunny requested a review from a team as a code owner November 17, 2026 23:15
@aws-sam-tooling-bot

aws-sam-tooling-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

🧪 Hands-on test: No problems observed in 6 scenarios

Commit 1a3789b · build LambdaToolingHandsOn-NoDocker:4e91532e-9660-435a-8f2d-0e3a0b9ecf7c. The plan's scenarios ran on an isolated build host; a problem is reported only if it reproduced at least twice. Passing scenarios show only that these checks behaved as expected, not that the change is correct.

Scenarios

Scenario Planned check Result Runner's note
S1 Main fix: uv_prune naming the project being built (spelled differently from [project].name) fails validation instead of… ✅ pass Head: uv_prune ["PruneApp"] on project 'pruneapp' prints 'BUILD FAILED: PythonUvBuilder:Validation - Build option uv_prune cannot name the project being built (pruneapp)', EXIT=2, artifacts dir empty…
S2 PEP 503 matching (My_App vs my.app) in a source path with spaces and unicode, and a normal prune of a real dependency i… ✅ pass Source dir 'my app ü' with project name My_App. Head: uv_prune ["six","my.app"] fails with 'Build option uv_prune cannot name the project being built (My_App)', EXIT=2; uv_prune ["six"] gives BUILD O…
S3 uv workspace: pruning another workspace member stays allowed; pruning the member being built fails. ✅ pass Copied the repo's testdata/workspace (uv.lock removed) and built the app member. Head: uv_prune ["workspace-lib"] gives BUILD OK, EXIT=0, artifacts main.py and pyproject.toml with no workspace_lib; u…
S4 Unreadable pyproject.toml with uv_prune: the new check is skipped, so uv reports the problem and the Python TOML parser… ✅ pass Head with a malformed pyproject.toml ('[project' unclosed) and uv_prune ["six"]: prints 'BUILD FAILED: PythonUvBuilder:ResolveDependencies - UV package build failed: Could not determine the UV worksp…
S5 Existing configs keep working: uv_all_extras true together with uv_prune on a project with a name builds and installs t… ✅ pass Head: project 'extrasapp' with uv_all_extras true and uv_prune ["six"] gives BUILD OK, EXIT=0. The artifacts contain idna/ and idna-3.10.dist-info (from the dns extra), with no six.py and no extrasap…
S6 The repo's own python_uv tests, including the new unit cases and the extended prune integration test, pass with a real … ✅ pass Head unit+functional python_uv tests: 171 passed, 53 subtests passed. These include test_prune_of_the_project_itself_fails (5 cases), test_prune_of_a_similar_name_is_allowed, test_prune_without_a_pro…
Runner's notes in full
  • S1: Head: uv_prune ["PruneApp"] on project 'pruneapp' prints 'BUILD FAILED: PythonUvBuilder:Validation - Build option uv_prune cannot name the project being built (pruneapp)', EXIT=2, artifacts dir empty. Base: uv warns the lock requirements file has no dependencies, prints BUILD OK, EXIT=0, and the artifacts are app.py, pyproject.toml and uv.lock with no six.py or idna/. This confirms the bug on base and the fix on head. Venvs were in /work/scratch/venv-head and venv-base (Python 3.11.18, uv 0.13.9); projects were built under /work/scratch instead of /tmp/ho.
  • S2: Source dir 'my app ü' with project name My_App. Head: uv_prune ["six","my.app"] fails with 'Build option uv_prune cannot name the project being built (My_App)', EXIT=2; uv_prune ["six"] gives BUILD OK, EXIT=0, artifacts contain idna/ and idna-3.10.dist-info, no six.py. No traceback. Base: the first build passes (EXIT=0) with no dependencies installed (same warning as S1); the second build matches head.
  • S3: Copied the repo's testdata/workspace (uv.lock removed) and built the app member. Head: uv_prune ["workspace-lib"] gives BUILD OK, EXIT=0, artifacts main.py and pyproject.toml with no workspace_lib; uv_prune ["Workspace_App"] fails with 'cannot name the project being built (workspace-app)', EXIT=2. Base: both builds give BUILD OK, EXIT=0, the second with the empty-requirements warning.
  • S4: Head with a malformed pyproject.toml ('[project' unclosed) and uv_prune ["six"]: prints 'BUILD FAILED: PythonUvBuilder:ResolveDependencies - UV package build failed: Could not determine the UV workspace root ...' carrying uv's 'TOML parse error at line 1, column 9 ... unclosed table', EXIT=2. No Python traceback, no TOMLDecodeError, and no 'cannot name the project being built' text. Base was not run (compare_base false).
  • S5: Head: project 'extrasapp' with uv_all_extras true and uv_prune ["six"] gives BUILD OK, EXIT=0. The artifacts contain idna/ and idna-3.10.dist-info (from the dns extra), with no six.py and no extrasapp-*.dist-info.
  • S6: Head unit+functional python_uv tests: 171 passed, 53 subtests passed. These include test_prune_of_the_project_itself_fails (5 cases), test_prune_of_a_similar_name_is_allowed, test_prune_without_a_project_name_is_left_to_uv (3 cases) and both test_options_are_passed_to_the_build_action cases. Integration -k 'prune or build_options or workspace': 8 passed, including test_workflow_prunes_runtime_provided_packages for both experimental flag variants. The ERROR lines in the logs are captured log output from negative tests, not failures. Python 3.11 only, so the tomli fallback for Python 3.10 was not exercised.

🤖 Automated hands-on test — not a review approval · model claude-opus-5.5 · Kiro kiro-cli 2.33.1 · build LambdaToolingHandsOn-NoDocker:4e91532e-9660-435a-8f2d-0e3a0b9ecf7c · commit 1a3789b

History (3)
Commit Result When (UTC) Build
1a3789b No problems observed 2026-11-19 00:36 LambdaToolingHandsOn-NoDocker:4e91532e-9660-435a-8f2d-0e3a0b9ecf7c
52d0524 No problems observed 2026-11-18 19:19 LambdaToolingHandsOn-NoDocker:34ef6c47-5919-41c7-8e2f-de0cfa056b80
065b21f No problems observed 2026-11-17 23:22 LambdaToolingHandsOn-NoDocker:ddca8cda-1019-46ee-a4f7-8b95268a4325

@bnusunny
bnusunny force-pushed the fix/python-uv-966-followups branch from 838d746 to 52d0524 Compare November 18, 2026 19:13
@bnusunny bnusunny mentioned this pull request Nov 18, 2026
1 task done

@vicheey vicheey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! A couple of small things:

  • DESIGN.md lists the cases where the build fails instead of ignoring an option (under "Build options"). Could you add this one there?
  • Optional: test_prune_without_a_project_name_is_left_to_uv doesn't have a case for a non-string name (name = 1) or a non-table project (project = "x"), so the two isinstance checks in _project_name aren't covered.

@bnusunny
bnusunny enabled auto-merge (squash) November 19, 2026 00:40
@bnusunny
bnusunny merged commit c200cc7 into aws:develop Nov 19, 2026
125 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants